package com.mhkj.base.amount.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mhkj.base.amount.entity.ExamineStandard;
import com.mhkj.base.amount.service.ExamineStandardService;
import com.mics.core.common.componet.JsonHandler;
import com.mics.core.common.componet.Pagination;
import com.mics.core.common.componet.ResponseMessage;
import com.mics.core.system.base.controller.BaseController;
import com.mics.core.system.organizational.bean.Employee;
import com.mics.core.system.organizational.service.OrgService;
import com.mics.core.system.rbac.service.DictionaryService;

/**
 * 考核标准
 */

@Controller
@RequestMapping(value = "/examine/standard")
public class ExamineStandardController extends BaseController<ExamineStandard> {

	@Resource
	private ExamineStandardService examineStandardService;
	@Resource
	private OrgService orgService;
	@Resource
	private DictionaryService dictionaryService;
	@Resource
	private JsonHandler jsonHandler;
	
	/**
	 * 添加
	 */
	@RequestMapping(value="/add", method=RequestMethod.POST)
	@ResponseBody
	public ResponseMessage save(ExamineStandard entity) {
		String message = examineStandardService.save(entity);
		return ResponseMessage.createMessage("ok".equals(message), message);
	}

	/**
	 * 修改
	 */
	@RequestMapping(value="/edit", method=RequestMethod.POST)
	@ResponseBody
	public ResponseMessage edit(ExamineStandard entity) {
		String message = examineStandardService.edit(entity);
		return ResponseMessage.createMessage("ok".equals(message), message);
	}

	/**
	 * 删除
	 */
	@RequestMapping(value="/del", method=RequestMethod.POST)
	@ResponseBody
	public ResponseMessage del(ExamineStandard entity) {
		String message = examineStandardService.del(entity);
		return ResponseMessage.createMessage("ok".equals(message), message);
	}

	/**
	 * 查询列表
	 */
	@RequestMapping(value = "/list", method = RequestMethod.POST)
	@ResponseBody
	public void list(HttpServletResponse response,ExamineStandard entity, Integer pageIndex, Integer pageSize) {
		Pagination<ExamineStandard> findPage = examineStandardService.findPage(entity, pageIndex, pageSize);
		List<ExamineStandard> data = findPage.getData();
		for (ExamineStandard examineStandard : data) {
			Employee employeeInfo = orgService.employeeInfo(examineStandard.getCreateBy());
			examineStandard.setCreateName(employeeInfo.getName());
		}
		jsonHandler.sendJsonString(response, true, "获取数据成功", findPage, new String[]{
			"id","method","keyProperty.value","day","amount","createName","createDate"	
		}, "id","method","keyPropertyName","day","amount","createName","createDate"	);

	}

	/**
	 * 根据Id查询s
	 */
	@RequestMapping(value = "/info", method = RequestMethod.POST)
	@ResponseBody
	public void info(HttpServletResponse response,Long id) {
		ExamineStandard ExamineStandard = examineStandardService.getById(id);
		jsonHandler.sendJsonString(response, true, "获取数据成功", ExamineStandard, new String[]{
				"id","method","keyProperty.id","day","amount","createName","createDate","remark"	
			}, "id","method","keyPropertyId","day","amount","createName","createDate","remark"	);

	}



}
